2023/12/231453字符

const shape = {
  radius: 10,
  diameter() {
    return this.radius * 2;
  },
  perimeter: () => 2 * Math.PI * this.radius,
};

console.log(shape.diameter());  //--> 20
console.log(shape.perimeter());  //--> NaN
+ true;  //--> 1
+ 'str';  //--> NaN
+ '';  //--> false
! '';  //--> 0
+ NaN;  //--> NaN
! NaN;  //--> true
let a = 3;
let b = new Number(3);
let c = 3;

console.log(a == b);  //--> true
console.log(a === b);  //--> false
console.log(b === c);  //--> false
function bark() {
  console.log('Woof!');
}

bark.animal = 'dog';  // Nothing, this is totally fine!
function Person(firstName, lastName) {
  this.firstName = firstName;
  this.lastName = lastName;
}

const member = new Person('Lydia', 'Hallie');
Person.getFullName = function() {
  return `${this.firstName} ${this.lastName}`;
};

console.log(member.getFullName());  // TypeError
let number = 0;
console.log(number++);  //--> 0
console.log(++number);  //--> 2
console.log(number);  //--> 2
function getPersonInfo(one, two, three) {
  console.log(one);
  console.log(two);
  console.log(three);
}

const person = 'Lydia';
const age = 21;

getPersonInfo`${person} is ${age} years old`;  //--> ["", " is ", " years old"] "Lydia" 21
function getAge(...args) {
  console.log(typeof args);
}

getAge(21);  //--> object